package com.example.demo.repository;

import com.example.demo.bean.UserTimetableZJBean;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;
import java.util.Map;

/**
 * @author zhangbiao
 * @date 2020/6/25 11:00
 * @desc 描述
 */
public interface UserTimetableZJRepository extends JpaRepository<UserTimetableZJBean, String> {

    public void deleteByObjId(String obj_id);

    public void deleteByUserId(String user_id);

    public void deleteByTimetableId(String timetable_id);

    //https://blog.csdn.net/linzhiqiang0316/article/details/79177077  JPA查询大全
    @Query(value = "SELECT tt.*,u.nickname FROM t_usertimetable_zj tt,t_user u WHERE timetable_id = ?1 AND tt.user_id = u.obj_id", nativeQuery = true)
    public List<Map<String, Object>> findUserTimeTableBean(String timetable_id);

    @Query(value = "SELECT tt.*,u.course_name FROM t_usertimetable_zj tt,t_timetable u WHERE user_id = ?1 AND tt.timetable_id = u.obj_id", nativeQuery = true)
    public List<Map<String, Object>> findTimeTableBean(String user_id);
}
